<?php

class Admin_Model_User extends Zend_Db_Table_Abstract
{
    protected $_name = "core_users";
    
    /**
     * 创建用户
     *
     * @param unknown_type $data
     */
    public function createUser($data = array())
    {
        $row = $this->createRow();
        if (count($data) > 0){
            foreach ($data as $key=>$value){
                $row->$key = $value;
            }
            $row->save();
            return $row->id;
        }
        else{
            return null;
        }
    }
    
    /**
     * 删除用户
     *
     * @param unknown_type $id
     * @throws Zend_Exception
     */
    public function deleteUser($id){
        $row = $this->find($id)->current();
        if ($row) {
            $row->delete();
        }
        else{
            throw new Zend_Exception('删除用户出错！没有找到该用户。');
        }
    }
}

